<?php
    if (empty($type)) { // Edit form        
        $product = NULL;
    }
?>

<div class="row">
    <div class="form-group"> 
        <div class="col-sm-6">
            <a href="{{ route('admin.product.index') }}" class="btn default"><i class=' icon-action-undo'></i> Quay lại</a>
        </div>
        <div class="col-sm-6">
            {{ Form::button("<i class='icon-layers'></i> Lưu", array('type' => 'submit', 'class' => 'btn btn-success pull-right')) }}
        </div>
    </div>
</div>

<div class="tabbable-custom">
	<ul class="nav nav-tabs">
	    <li class="active"><a href="#tab-en" data-toggle="tab">English</a></li>
	    <li><a href="#tab-vi" data-toggle="tab">Vietnamese</a></li>
	    <li><a href="#tab-general" data-toggle="tab">Bổ sung</a></li>
	</ul>
	
	<!-- Tab panes -->
	<div class="tab-content">
	    <div class="tab-pane active" id="tab-en">      
	        <div class="form-group col-sm-12">
                {{ Form::label('name_en', 'Tên SP', array('class' => 'control-label')) }}
                <div>
                    {{ Form::text('name_en', !empty($product) ? $product->name_en : null, array('class' => 'form-control')) }}
                </div>
            </div>
            <div class="form-group col-sm-12">
                {{ Form::label('note_en', 'Ghi chú thêm', array('class' => 'control-label')) }}
                <div>
                    {{ Form::text('note_en', !empty($product) ? $product->note_en : null, array('class' => 'form-control')) }}
                </div>
            </div>
	        <div class="form-group col-sm-12">
	            {{ Form::label('description_en', 'Chi tiết sản phẩm', array('class' => 'control-label')) }}
	            <div>
	                {{ Form::textarea('description_en', !empty($product) ? $product->description_en : null, array('class' => 'form-control ckeditor', 'id' => 'create-content-en')) }}
	            </div>
	        </div>
	        <div class='clear'></div>
	    </div>
	    
	    <div class="tab-pane" id="tab-vi">      
            <div class="form-group col-sm-12">
                {{ Form::label('name_vi', 'Tên SP', array('class' => 'control-label')) }}
                <div>
                    {{ Form::text('name_vi', !empty($product) ? $product->name_vi : null, array('class' => 'form-control')) }}
                </div>
            </div>
            <div class="form-group col-sm-12">
                {{ Form::label('note_vi', 'Ghi chú thêm', array('class' => 'control-label')) }}
                <div>
                    {{ Form::text('note_vi', !empty($product) ? $product->note_vi : null, array('class' => 'form-control')) }}
                </div>
            </div>
            <div class="form-group col-sm-12">
                {{ Form::label('description_vi', 'Chi tiết sản phẩm', array('class' => 'control-label')) }}
                <div>
                    {{ Form::textarea('description_vi', !empty($product) ? $product->description_vi : null, array('class' => 'form-control ckeditor', 'id' => 'create-content-en')) }}
                </div>
            </div>
            <div class='clear'></div>
        </div>
	    
	    <div class="tab-pane" id="tab-general">
	        <div class="row">
    	        <div class='form-group col-sm-12'>
    	            <div id='uploaded-files'>
    	                <?php if (!empty($type)) :?>
    	                    @if (!empty($product->media_id))
    	                        <?php  $media = Media::find($product->media_id); ?>
    	                        <div class="item-upload">
    	                                    <div class='item-image'>
    	                                        <input type="hidden" name="file" value="{{ $media->id }}">
    	                                        <a class="thumb thumbnail-admin" href="{{ $media->path.$media->original }}" title="{{ $media->caption }}" style="background: url('{{ $media->path.$media->thumb }}') no-repeat; background-size: cover; background-position: 70% 100%;"></a>
    	                                        <div class='tools tools-bottom'>
    	                                            @if ($media->type != Config::get('config.media_type.file'))
    	                                            <a class="edit-caption-item" href="javascript:void(0)" id="item-image-{{ $media->id }}" data-id="{{ $media->id }}">
    	                                                <i class="fa fa-pencil"></i>
    	                                            </a>
    	                                            <input type='hidden' class='caption-value' value="{{ $media->caption }}" />
    	                                            @endif
    	                                            <a class="cancel-item-upload" href="javascript:void(0)" data-href="{{ URL::to('/media/delete/'.$media->id) }}">
    	                                                <i class="fa fa-times text-danger"></i>
    	                                            </a>
    	                                            <input type='hidden' class='caption-value' value=""/>
    	                                        </div>
    	                                    </div>
    	                                    <span class="name-item-upload" title="{{ $media->name.'.'.$media->extension }}">{{ $media->name.'.'.$media->extension }}</span>
    	                                </div>
    	                    @endif
    	                <?php endif; ?>
    	            </div>
    	            <a class='btn btn-primary btn-upload'data-format='image'>
    	                Hình ảnh <i class=' icon-cloud-upload '></i>
    	            </a>
    	        </div>
    	    </div>
    	    <div class="row">
    	        <div class="form-group col-sm-12">
                    <div>
                        {{ Form::text('code', !empty($product) ? $product->code : null, array('class' => 'form-control', 'placeholder' => 'Mã sản phẩm (Nếu không nhập hệ thống sẽ tự sinh mã cho sản phẩm)')) }}
                    </div>
                </div>
    	    </div>
    	    <div class="row">
    	        <div class="form-group col-sm-6">
    	            <div>
    	                <select class="form-control has-custom-select" name='category'>
    	                    <?php $categories = Category::whereRaw('status = ? and is_deleted = ?', array(1,0))->get(); ?>
    	                    <optgroup label="Nữ">
    	                         <?php
    	                            foreach ($categories as $cate) {
    	                                if ($cate->parent_id == 1) {
    	                                    echo "<option value='$cate->id'>".$cate->name_vi."</option>";
    	                                }
    	                            }
    	                         ?>
    	                     </optgroup>
    	                     <optgroup label="Nam">
    	                         <?php
    	                            foreach ($categories as $cate) {
    	                                if ($cate->parent_id == 2) {
    	                                    echo "<option value='$cate->id'>".$cate->name_vi."</option>";
    	                                }
    	                            }
    	                         ?>
    	                     </optgroup>
    	                     <optgroup label="Trẻ em">
    	                         <?php
    	                            foreach ($categories as $cate) {
    	                                if ($cate->parent_id == 3) {
    	                                    echo "<option value='$cate->id'>".$cate->name_vi."</option>";
    	                                }
    	                            }
    	                         ?>
    	                     </optgroup>
    	                     <optgroup label="Quần áo & túi xách">
                                 <?php
                                    foreach ($categories as $cate) {
                                        if ($cate->parent_id == 4) {
                                            echo "<option value='$cate->id'>".$cate->name_vi."</option>";
                                        }
                                    }
                                 ?>
                             </optgroup>
    	                </select>
    	            </div>
    	        </div>
    	        <div class="form-group col-sm-6">
    	            <div>
    	                {{ Form::text('madein', !empty($product) ? $product->madein : null, array('class' => 'form-control', 'placeholder' => 'Xuất xứ')) }}
    	            </div>
    	        </div>
    	    </div>
	        <div class="row">
	            <div class="col-sm-6 form-group">
                    <div>
                        {{ Form::text('price_original', !empty($product) ? $product->price_original : null, array('class' => 'form-control', 'placeholder' => 'Giá gốc (VNĐ)')) }}
                    </div>
                </div>
                <div class="col-sm-6 form-group">
                    <div>
                        {{ Form::text('price_sale', !empty($product) ? $product->price_sale : null, array('class' => 'form-control', 'placeholder' => 'Giá bán sỉ (VNĐ)')) }}
                    </div>
                </div>
	        </div>
	        <div class="row">
    	        <div class="form-group col-sm-6">
    	            <div class="">
    	                {{ Form::text('size', !empty($product) ? $product->size : null, array('class' => 'form-control', 'placeholder' => 'Kích thước (S, M..)')) }}
    	            </div>
    	        </div>
    	        <div class="form-group col-sm-6 required">
    	            <div>
    	                {{ Form::text('weight', !empty($product) ? $product->weight : null, array('class' => 'form-control', 'placeholder' => 'Trọng lượng (g)')) }}
    	            </div>
    	        </div>
	        </div>
	        <div class="row">
    	        <div class="form-group col-sm-6 required">
    	            <div>
    	                {{ Form::text('color', !empty($product) ? $product->color : null, array('class' => 'form-control', 'placeholder' => 'Màu sắc (đỏ, xanh..)')) }}
    	            </div>
    	        </div>
    	        <div class="form-group col-sm-6 required">
    	            <div>
    	                {{ Form::text('material', !empty($product) ? $product->material : null, array('class' => 'form-control', 'placeholder' => 'Chất liệu (conton..)')) }}
    	            </div>
    	        </div>
    	    </div>
	        <div class="clear"></div>
	    </div>
	   
	</div>
</div>